package com.ruoyi.generator.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.generator.domain.FromBuildPage;
import com.ruoyi.generator.service.IFromBuildPageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 构建页面Controller
 *
 * @author ZGL
 * @date 2024-12-12
 */
@RestController
@RequestMapping("/generator/FromBuildPage")
public class FromBuildPageController extends BaseController
{
    @Autowired
    private IFromBuildPageService fromBuildPageService;

    /**
     * 查询构建页面列表
     */
    @PreAuthorize("@ss.hasPermi('generator:FromBuildPage:list')")
    @GetMapping("/list")
    public TableDataInfo list(FromBuildPage fromBuildPage)
    {
        startPage();
        List<FromBuildPage> list = fromBuildPageService.selectFromBuildPageList(fromBuildPage);
        return getDataTable(list);
    }

    /**
     * 导出构建页面列表
     */
    @PreAuthorize("@ss.hasPermi('generator:FromBuildPage:export')")
    @Log(title = "构建页面", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FromBuildPage fromBuildPage)
    {
        List<FromBuildPage> list = fromBuildPageService.selectFromBuildPageList(fromBuildPage);
        ExcelUtil<FromBuildPage> util = new ExcelUtil<FromBuildPage>(FromBuildPage.class);
        util.exportExcel(response, list, "构建页面数据");
    }

    /**
     * 获取构建页面详细信息
     */
    @PreAuthorize("@ss.hasPermi('generator:FromBuildPage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fromBuildPageService.selectFromBuildPageById(id));
    }

    /**
     * 新增构建页面
     */
    @PreAuthorize("@ss.hasPermi('generator:FromBuildPage:add')")
    @Log(title = "构建页面", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FromBuildPage fromBuildPage)
    {
        return toAjax(fromBuildPageService.insertFromBuildPage(fromBuildPage));
    }

    /**
     * 修改构建页面
     */
    @PreAuthorize("@ss.hasPermi('generator:FromBuildPage:edit')")
    @Log(title = "构建页面", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FromBuildPage fromBuildPage)
    {
        return toAjax(fromBuildPageService.updateFromBuildPage(fromBuildPage));
    }

    /**
     * 删除构建页面
     */
    @PreAuthorize("@ss.hasPermi('generator:FromBuildPage:remove')")
    @Log(title = "构建页面", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fromBuildPageService.deleteFromBuildPageByIds(ids));
    }
}
